export const timeChange = time => {
  // 转换时间 time为毫秒数，返回格式为[xx,xx]
  let second = (Math.floor((time / 1000)) % 60) > 9 ? Math.floor((time / 1000)) % 60 : '0' + Math.floor((time / 1000)) % 60
  let minute = (Math.floor((Math.floor(time / 1000)) / 60)) > 9 ? Math.floor((Math.floor(time / 1000)) / 60) : '0' + Math.floor((Math.floor(time / 1000)) / 60)
  return [minute, second]
}
export const artistsShow = arList => {
  // 返回作者名字，返回格式为[x,x,x]
  return arList.map((val) => {
    return val.name
  })
}
export const listChange = list => {
  // 返回被处理后的数组，返回格式为[{xx:xx,...},{xx:xx,...}...]
  return list.map(val => {
    let time = []
    let date = null
    let tag = null
    let pic = null
    let id = null
    if (val.song) {
      time = timeChange(val.song.duration)
      date = val.name
      tag = artistsShow(val.song.artists)
      pic = val.picUrl
      id = val.id
    } else {
      time = timeChange(val.dt)
      date = val.name
      tag = artistsShow(val.ar)
      pic = val.al.picUrl
      id = val.id
    }
    return {
      date: date,
      tag: tag.join('&'),
      time: time[0] + ' : ' + time[1],
      pic: pic,
      id: id
    }
  })
}